package cn.ainit.edi.app;

import java.io.InputStream;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Map;

import cn.ainit.byf.station.Station;
import cn.ainit.common.DzEDIType;
import cn.ainit.edi.entity.SysDBSchemaCodeList;
import cn.ainit.edi.entity.SysDBSchemaInfo;
import cn.ainit.exchange.entity.ExchangeColumn;
import cn.ainit.exchange.entity.ExchangeGroup;
import cn.ainit.exchange.entity.ExchangeTable;
import cn.ainit.exchange.entity.MappingGroup;
import cn.ainit.exchange.entity.MappingTable;
import cn.ainit.sys.query.datastore.DataStore;
import cn.ainit.sys.query.entity.QueryJson;

public interface SysEDIService {
	/***
	 * 将解析出来的XML数据存入临时表
	 */
	void  saveXml(Map<String, Object> sqlMap);
	
	/***
	 * 日志
	 */
	void saveLog(String SUPPLY_SITE,String LOGTPYE,Boolean COMPLETESTATE,String MSG ,String FILENAME ,String STARTTIME ,String ENDTIME ,Long FILESIZE ,String TARGETURL ,String LOCALURL ,String DATATPYE ,String DATAID);
	/***
	 * 获取生成XML文件所需的数据
	 */
	Map<String,List<Map<String, Object>>> xmlIm(String TYPE,String CUSTOMRANGE,String SQLTITLE,String	SQL,String SQLITME);

	/***
	 * 执行语句
	 * @param createSql
	 * @return
	 * @throws Exception
	 */
	boolean executeSql(String createSql)throws Exception;
	/***
	 * 保存schema信息
	 * @param schemaInfo
	 * @return
	 * @throws Exception 
	 */
	boolean saveSchema(SysDBSchemaInfo schemaInfo) throws Exception;
	/***
	 * 保存schema文件
	 * @param inputStream
	 * @param string 
	 * @throws Exception
	 */
	boolean saveSchemaFile(InputStream inputStream, String string)throws Exception;
	/***
	 * 保存schema字段信息
	 * @param schemaColumns
	 * @throws Exception
	 */
	boolean saveSchemaColumns(List<SysDBSchemaCodeList> schemaColumns)throws Exception;
	/**
	 * 保存group
	 * @param group
	 * @return
	 * @throws Exception
	 */
	boolean saveExcGroup(ExchangeGroup group) throws Exception;
	/***
	 * 更新ExcGroup
	 * @param group
	 * @return
	 * @throws Exception
	 */
	boolean updateExcGroup(ExchangeGroup group) throws Exception;
	/***
	 * 查找所有的数据源
	 * @param pageSize
	 * @param pageNumber
	 * @param config
	 * @return
	 * @throws Exception
	 */
	QueryJson findExcGroup(int pageSize, int pageNumber, String config) throws Exception;
	/***
	 * 加载站点
	 * @return
	 * @throws Exception
	 */
	List<Station> queryStation() throws Exception;
	/***
	 * 查询数据源文件类型
	 * @return
	 * @throws Exception
	 */
	List<DzEDIType> querySourceType() throws Exception;
	/***
	 * 查找所有的数据源
	 * @return
	 * @throws Exception
	 */
	List<ExchangeGroup> queryAllExchangeG() throws Exception;
	/***
	 * 通过ID查找数据源
	 * @param groupId
	 * @return
	 * @throws Exception
	 */
	List<ExchangeGroup> queryExchangeGById(String groupId) throws Exception;
	/***
	 * 加载所有的
	 * @param groupId
	 * @param string 
	 * @return
	 * @throws Exception
	 */
	List<ExchangeTable> queryExcTabByGroupId(String groupId, String string) throws Exception;
	/**
	 * 保存ExcTable
	 * @param exchangeTable
	 * @return
	 * @throws Exception
	 */
	boolean saveExcTable(ExchangeTable exchangeTable)throws Exception;
	/**
	 * 更新ExcTable
	 * @param exchangeTable
	 * @return
	 * @throws Exception
	 */
	boolean updateExcTable(ExchangeTable exchangeTable) throws Exception;
	/**
	 * 删除ExchangeTable
	 * @param groupTableId
	 * @return
	 * @throws Exception
	 */
	boolean delExcTable(String groupTableId) throws Exception;
	/***
	 * 通过ID查找枚举列
	 * @param groupId
	 * @param groupTableId
	 * @return
	 * @throws Exception
	 */
	List<ExchangeColumn> queryExcClnByIds(String groupId, String groupTableId) throws Exception;
	/***
	 * 通过ID插座ExchangeTable
	 * @param groupTableId
	 * @return
	 * @throws Exception
	 */
	ExchangeTable loadExcTableById(String groupTableId) throws Exception;
	/***
	 * 根据ID加载数据源
	 * @param dataSelectDsid
	 * @return
	 * @throws Exception
	 */
	DataStore loadDataStoreById(String dataSelectDsid) throws Exception;
	/***
	 * 获取sql语句的所有字段
	 * @param sqlText
	 * @return
	 * @throws Exception
	 */
	List<String> getSqlColumns(String sqlText) throws Exception;
	/***
	 * 通过DSId查找数据库中的所有字段
	 * @param dataSelectDsid
	 * @return
	 * @throws Exception
	 */
	List<ExchangeColumn> queryExcClnFromDS(String dataSelectDsid) throws Exception;
	/***
	 * 批量保存ExchangeColumn
	 * @param excColumns
	 * @return
	 * @throws Exception
	 */
	boolean saveExcClns(List<ExchangeColumn> excColumns) throws Exception;
	/***
	 * 删除所有旧的字段
	 * @param sqlTxt
	 * @param groupId
	 * @param groupTableId
	 * @return
	 * @throws Exception
	 */
	boolean delExcClnsByIds(String sqlTxt, String groupId, String groupTableId)throws Exception;
	/***
	 * 查找mappingGroup
	 * @param rows
	 * @param page
	 * @param config
	 * @return
	 * @throws Exception
	 */
	QueryJson queryMappingGroup(int rows, int page, String config)throws Exception;
	/***
	 * 加载对照信息
	 */
	List queryDzSource(String sql)throws Exception;
	/***
	 * 保存MappingGroup
	 * @param mappingGroup
	 * @throws Exception
	 * @return
	 */
	boolean saveMapGroup(MappingGroup mappingGroup)throws Exception;
	/***
	 * 更新MappingGroup
	 * @param mappingGroup
	 * @return
	 * @throws Exception
	 */
	boolean updateMapGroup(MappingGroup mappingGroup)throws Exception;
	/***
	 * 加载所有的MappingTable by GroupId
	 * @param rows
	 * @param page
	 * @param mappingGroupId
	 * @return
	 * @throws Exception
	 */
	QueryJson queryMappingTable(int rows, int page, String mappingGroupId)throws Exception;
	/***
	 * 保存映射项
	 * @param mappingTable
	 * @return
	 * @throws Exception
	 */
	boolean saveMapTable(MappingTable mappingTable)throws Exception;
	/**
	 * 更新映射项
	 * @param mappingTable
	 * @return
	 * @throws Exception
	 */
	boolean updateMapTable(MappingTable mappingTable)throws Exception;


}
